package com.gzz.orchid.context.application.inventory.convert;

import com.gzz.orchid.context.application.inventory.command.WarehouseSaveCmd;
import com.gzz.orchid.context.application.inventory.pojo.WarehouseDto;
import com.gzz.orchid.context.application.inventory.pojo.WarehouseVo;
import com.gzz.orchid.context.infrastructure.definition.Status;
import com.gzz.orchid.context.infrastructure.persistence.entity.inv.InvWarehousePo;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;

/**
 * @author higmd
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE, imports = {Status.class})
public interface WarehouseConverter {
    WarehouseConverter INSTANCE = Mappers.getMapper(WarehouseConverter.class);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))")
    })
    WarehouseVo mapVo(InvWarehousePo po);

    @Mappings({
            @Mapping(target = "status", expression = "java(Status.parse(po.getStatus()))")
    })
    WarehouseDto mapDto(InvWarehousePo po);

    //
    void updatePo(@MappingTarget InvWarehousePo po, WarehouseSaveCmd cmd);
}
